package com.haoshuang.zhouzhoubang.ui.adapter

import com.haoshuang.zhouzhoubang.databinding.ItemViolationDeductMoneyOrderListBinding
import com.haoshuang.zhouzhoubang.model.bean.BalanceDetailGroupListBean
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.core.setOnItemClick
import com.mufeng.libs.utils.view.vertical

/**
 *
 */
class ViolationDeductMoneyOrderListAdapter(
    data: MutableList<BalanceDetailGroupListBean.BalanceDetailGroupBean>,
    private val onItemClick: (item: BalanceDetailGroupListBean.BalanceDetailGroupBean.BalanceDetailBean?, position: Int) -> Unit
) : BaseBindingQuickAdapter<BalanceDetailGroupListBean.BalanceDetailGroupBean, ItemViolationDeductMoneyOrderListBinding>(
    data
) {

    override fun onBindViewHolder(
        holder: BaseBindingHolder,
        position: Int,
        item: BalanceDetailGroupListBean.BalanceDetailGroupBean?
    ) {
        holder.getViewBinding<ItemViolationDeductMoneyOrderListBinding>().apply {
            tvDate.text = item?.add_date
            val adapter = ViolationDeductMoneyOrderListChildAdapter(
                item?.list?.toMutableList() ?: mutableListOf()
            )
            recyclerView.vertical()
                .adapter = adapter
            adapter.setOnItemClick { view, position ,item->
                val i = adapter.getItem(position)
                onItemClick(i, position)
            }
        }
    }
}
